/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package admin.util;


import ejb.entity.Account;
import javax.servlet.http.HttpServletRequest;

/**
 *
 * @author Nothing4ever
 */
public class SessionManager {
    
    public final static String USERNAME_SESSION = "USERNAME_SESSION";
    
    public static void initUserLogin (Account account, HttpServletRequest req){
        req.getSession().setAttribute(SessionManager.USERNAME_SESSION, account);
    }
    public static void resetUserLogin (HttpServletRequest req){
        req.getSession().setAttribute(SessionManager.USERNAME_SESSION, null);
    }
    
    public static Account getAccount(HttpServletRequest req){
        try {
             return (Account)req.getSession().getAttribute(SessionManager.USERNAME_SESSION);
        }
        catch (Exception e){
            e.printStackTrace();
        }
        return null;
    }
    
    
}
